package com.diudiutechnology.www.yadiudiu.yadiudiu.singlecall.MyAdapter;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.diudiutechnology.www.yadiudiu.yadiudiu.model.BuyACarFragmentModel;
import com.diudiutechnology.www.yadiudiu.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/8/23.
 */

public class ResumeDetailsActivityAdapter extends BaseAdapter {

    private Context mContext;

    List<BuyACarFragmentModel> model= new ArrayList<>();
    public ResumeDetailsActivityAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return model.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    public void addItem( List<BuyACarFragmentModel> model){

        this.model=model;
        notifyDataSetChanged();
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.itme_resume_details, null);
            holder.position = (TextView) convertView
                    .findViewById(R.id.position);
            holder.time = (TextView) convertView
                    .findViewById(R.id.time);
            holder.evaluation = (TextView) convertView
                    .findViewById(R.id.evaluation);
            holder.leaving_reason = (TextView) convertView
                    .findViewById(R.id.leaving_reason);
            holder.line = (TextView) convertView
                    .findViewById(R.id.line);
            holder.line1 = (TextView) convertView
                    .findViewById(R.id.line1);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.position.setText(Html.fromHtml("销售员<font color='#666666'>  |  年薪：10万</font>"));
        holder.time.setText(Html.fromHtml("工作时间：<font color='#666666'>2015.08.09-2017.02.17</font>"));
        holder.evaluation.setText(Html.fromHtml("公司评价：<font color='#666666'>执行力-中</font>"));
        holder.leaving_reason.setText(Html.fromHtml("离职原因：<font color='#666666'>自动离职</font>"));
        if (position==(model.size()-1)){
            holder.line.setVisibility(View.GONE);
            holder.line1.setVisibility(View.GONE);
        }else {
            holder.line.setVisibility(View.VISIBLE);
            holder.line1.setVisibility(View.VISIBLE);
        }
        return convertView;
    }

    class ViewHolder {
        TextView position;
        TextView time;
        TextView evaluation;
        TextView leaving_reason;
        TextView  line;
        TextView  line1;
    }
}

